package com.foreveross.fetl.core.domain.task;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.domain.BaseOracleEntity;
import com.foreveross.fetl.core.domain.task.repository.IExchangeRateRepository;

@javax.persistence.Entity
@Table(name = "fdc_exchange_rate")
public class ExchangeRateEntity extends BaseOracleEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2836702270382549636L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	//货币名字 如：美元
	@Column(name = "NAME")
	private String name;
	
	//货币code 如：USD
	@Column(name = "CODE")
	private String code;
	
	//对人民币的汇率 如：6.22110
	@Column(name = "REFE_PRICE")
	private Double refePrice;
	
	//哪一天的汇率   20140416
	@Column(name = "DATE")
	private String date;
	
	//最后更新时间
	@Column(name = "LAST_TIME")
	private Date lastTime;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Double getRefePrice() {
		return refePrice;
	}

	public void setRefePrice(Double refePrice) {
		this.refePrice = refePrice;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public Date getLastTime() {
		return lastTime;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}
	
	@Override
	public IExchangeRateRepository getBaseEntityRepository() {
		return InstanceFactory.getInstance(IExchangeRateRepository.class);
	}
	
	public void save(ExchangeRateEntity entity){
		getBaseEntityRepository().save(entity);
	}
	
	public void delete(ExchangeRateEntity entity){
		getBaseEntityRepository().delete(entity);
	}
	
	public List<ExchangeRateEntity> findByCondition(String name ,String code,String date){
		return getBaseEntityRepository().findByCondition(name, code, date);
	}

}
